package model;

import java.io.FileNotFoundException;

import init.DBManagement;
public class ConceptualMap{
	/**
	 * 
	 * 
	 * @param int_plan
	 * @param byte_file
	 * @param str_descripcion
	 * @return
	 */
	public static boolean upload(String str_subjectId , byte[] byte_file, String str_nombre){
		boolean bol_retVal = false;
		DBManagement db = new DBManagement();
		
		String str_updateName = 
			" UPDATE PLAMSTB "+
			" SET    MAPA_CONCEPTUAL_NAME = '"+str_nombre+"' "+
			" WHERE  MATERIA_TK = '"+str_subjectId+"'";
		db.executeQuery(str_updateName);
		
		String str_table = "PLAMSTB";
		String str_id = "MATERIA_TK";
		String str_blob = "MAPA_CONCEPTUAL";
		
		bol_retVal = db.uploadBlob(str_table, str_id, str_blob, byte_file, str_subjectId);
		
		return bol_retVal;
	}
	
	public static String view( String str_subjectId, String str_path ) throws Exception{
		DBManagement db = new DBManagement();
		String str_createdFile = "";
		try{
			str_createdFile = db.getFile("PLAMSTB", "MATERIA_TK", "MAPA_CONCEPTUAL", str_subjectId, str_path, "MAPA_CONCEPTUAL_NAME");
		}catch( FileNotFoundException ex ){}
		return str_createdFile;
	}
}
